package com.lifeng;

import lombok.Data;

public class Dome {
    public static void main(String[] args) {
        Node node1 = new Node("1");
        Node node2 = new Node("2");
        Node node3 = new Node("3");
        Node node4 = new Node("4");
        node3.setNext(node4);
        node2.setNext(node3);
        node1.setNext(node2);
        print(node1);

        System.out.println(getLast(node1).getName());
    }

    public static void print(Node node){
        if(node == null){
            return;
        }else{
            System.out.print(node.getName()+"->");
            if(node.getNext() != null){
                print(node.getNext());
            }else{
                System.out.print("null");
            }
        }

    }

    public static Node getLast(Node node){
        Node tmp = node.getNext();
        while(tmp!= null){
            System.out.println(tmp.getName());
            if(tmp.getNext() == null){
                return tmp;
            }
            tmp = tmp.getNext();
        }
        return null;
    }

    public static Node reverse(Node node){
        if(node == null){
            return null;
        }else{
            return null;
        }
    }
}

@Data
class Node{
    private String name;
    private Node next;
    public Node(){

    }
    public Node(String name){
        this.name = name;
    }
}
